Skip to content

fix(api): fill {{note}} in webhook bodies when an alert fires - #3645

Merged
jordan-simonovski merged 1 commit into
mainfrom
jordansimonovski/alert-note-in-webhooks
Nov 13, 2026
Merged

jordan-simonovski merged 1 commit into
mainfrom
jordansimonovski/alert-note-in-webhooks

Conversation

@jordan-simonovski

Copy link
Copy Markdown
Contributor

Summary

{{note}} rendered empty in Generic and incident.io webhook bodies whenever a real alert fired. The alert worker left note off the alert it hands to the template, and "Send test" hid the bug because it uses a hard-coded sample note. Closes #3644.

  • Webhook bodies now include the alert's note when the alert fires.
  • Message and title templates can also use {{alert.note}}.
  • No breaking changes: bodies without {{note}} render as before.
  • The TILE generic webhook integration test now asserts the note in the delivered body; it fails on main.

How to reproduce

Starting point: yarn dev (needs the API and alert worker), plus a request receiver such as webhook.site.

On main:

  1. Create a Generic webhook pointing at the receiver, with body {"note": "{{note}}"}.
  2. Create an alert with a note that sends to that webhook, with a threshold it will cross.
  3. Click "Send test": the receiver gets the sample note.
  4. Let the alert fire: the receiver gets "note": "".

On this branch:

  1. Repeat step 4: the receiver gets the alert's note.

References

@jordan-simonovski
jordan-simonovski requested a review from a team as a code owner November 13, 2026 04:54
@vercel

vercel Bot commented Nov 13, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
hyperdx-oss Ready Ready Preview Nov 13, 2026 4:54am UTC
hyperdx-storybook Ready Ready Preview Nov 13, 2026 4:54am UTC

Request Review

@changeset-bot

changeset-bot Bot commented Nov 13, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f59eafb

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@hyperdx/api Patch
@hyperdx/app Patch
@hyperdx/otel-collector Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions Bot added the review/tier-2 Low risk — AI review + quick human skim label Nov 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔵 Tier 2 — Low Risk

Small, isolated change with no API route or data model modifications.

Why this tier:

  • Standard feature/fix — introduces new logic or modifies core functionality

Additional context: touches background tasks or the delivery pipeline lightly (1 lines, under the 30-line bar for Tier 4)

Review process: AI review + quick human skim (target: 5–15 min). Reviewer validates AI assessment and checks for domain-specific concerns.
SLA: Resolve within 4 business hours.

Stats
  • Production files changed: 1
  • Production lines changed: 1 (+ 3 in test files, excluded from tier calculation)
  • Branch: jordansimonovski/alert-note-in-webhooks
  • Author: jordan-simonovski

To override this classification, remove the review/tier-2 label and apply a different review/tier-* label. Manual overrides are preserved on subsequent pushes.

@github-actions

Copy link
Copy Markdown
Contributor

Duplicate code analysis

No new duplicate code introduced by this PR.


jscpd compared this branch against origin/main
across app, api and common-utils. Only new clones are listed; the codebase
currently holds 108 in total (1.18%).
Run yarn dupes locally to reproduce, or yarn dupes:all for the full picture.

@github-actions

Copy link
Copy Markdown
Contributor

PR Review

✅ No issues found.

@github-actions

Copy link
Copy Markdown
Contributor

Deep Review

✅ No critical issues found.

This is a minimal, correctly-scoped bug fix. fireChannelEvent built templateView.alert without a note field, so the pre-existing consumer at packages/api/src/tasks/checkAlerts/template.ts:770 (note: alert.note ?? '') always resolved to an empty string on a real alert fire, and packages/api/src/tasks/checkAlerts/transports/generic.ts:105 then published {{note}} as empty. Adding note: alert.note at packages/api/src/tasks/checkAlerts/index.ts:555 completes the chain.

Verified during review:

  • Types are sound. IAlert.note?: string | null flows through AlertInput into AlertMessageTemplateDefaultView.alert, and the consumer's ?? '' absorbs both null and undefined. No type error is introduced.
  • incident.io is covered by the added test. WebhookService.IncidentIO dispatches through handleSendGenericWebhook (transports/index.ts:23), the same path the new Generic-webhook assertion exercises, so there is no separate untested note path.
  • No injection risk. The note is JSON-escaped via escapeJsonString and passed as Handlebars view data (literal, not template source).
  • No contract change. note was already a published webhook template variable; the diff only populates it on the fire path.
  • Regression coverage is present. The TILE Generic-webhook integration test now asserts the delivered note in the body, which is the behavior being fixed.

Reviewers (9): correctness, testing, maintainability, project-standards, agent-native, learnings-researcher, security, api-contract, previous-comments.

@github-actions

Copy link
Copy Markdown
Contributor

E2E Test Results

✅ All tests passed • 467 passed • 1 skipped • 1370s

Status Count
✅ Passed 467
❌ Failed 0
⚠️ Flaky 1
⏭️ Skipped 1

Tests ran across 4 shards in parallel.

View full report →

@jordan-simonovski
jordan-simonovski merged commit c17fc16 into main Nov 13, 2026
32 checks passed

This branch was successfully deployed

2 active deployments
Preview – hyperdx-oss — f59eafb4 Deployed Nov 13, 2026 by vercel[bot]
Preview – hyperdx-storybook — f59eafb4 Deployed Nov 13, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review/tier-2 Low risk — AI review + quick human skim

Projects

None yet

Development

Successfully merging this pull request may close these issues.

{{note}} renders empty in webhook bodies when an alert fires

2 participants